package com.muyu.payment.domain.model;

import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import com.muyu.payment.domain.PaymentRefund;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;

/**
 * 支付退款申请分页查询返回模型
 *
 * @author muyu
 * @date 2025-09-16
 */
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "支付退款申请分页查询返回模型")
public class PaymentRefundPageQueryModel {
    /**
     * 主键
     */
    @Schema(name = "id", title = "主键", description = "主键")
    private Long id;

    /**
     * 退款申请号
     */
    @Schema(name = "refundNo", title = "退款申请号", description = "退款申请号")
    private String refundNo;

    /**
     * 原订单号
     */
    @Schema(name = "orderNo", title = "原订单号", description = "原订单号")
    private String orderNo;

    /**
     * 用户ID
     */
    @Schema(name = "userId", title = "用户ID", description = "用户ID")
    private Long userId;

    /**
     * 退款金额
     */
    @Schema(name = "refundAmount", title = "退款金额", description = "退款金额")
    private BigDecimal refundAmount;

    /**
     * 退款原因
     */
    @Schema(name = "refundReason", title = "退款原因", description = "退款原因")
    private String refundReason;

    /**
     * 退款状态(0:待审核,1:审核通过,2:审核拒绝,3:退款中,4:退款成功,5:退款失败)
     */
    @Schema(name = "refundStatus", title = "退款状态", description = "退款状态")
    private Integer refundStatus;

    /**
     * 审核人
     */
    @Schema(name = "auditor", title = "审核人", description = "审核人")
    private String auditor;

    /**
     * 审核时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(name = "auditTime", title = "审核时间", description = "审核时间")
    private Date auditTime;

    /**
     * 审核意见
     */
    @Schema(name = "auditOpinion", title = "审核意见", description = "审核意见")
    private String auditOpinion;

    /**
     * 第三方退款单号
     */
    @Schema(name = "thirdRefundNo", title = "第三方退款单号", description = "第三方退款单号")
    private String thirdRefundNo;

    /**
     * 退款时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(name = "refundTime", title = "退款时间", description = "退款时间")
    private Date refundTime;

    /**
     * 退款渠道
     */
    @Schema(name = "refundChannel", title = "退款渠道", description = "退款渠道")
    private String refundChannel;

    /**
     * 备注
     */
    @Schema(name = "remark", title = "备注", description = "备注")
    private String remark;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(name = "createTime", title = "创建时间", description = "创建时间")
    private Date createTime;

    /**
     * 创建者
     */
    @Schema(name = "createBy", title = "创建者", description = "创建者")
    private String createBy;

    /**
     * 信息构造器
     */
    public static PaymentRefundPageQueryModel infoBuild(PaymentRefund paymentRefund) {
        return PaymentRefundPageQueryModel.builder()
                .id(paymentRefund.getId())
                .refundNo(paymentRefund.getRefundNo())
                .orderNo(paymentRefund.getOrderNo())
                .userId(paymentRefund.getUserId())
                .refundAmount(paymentRefund.getRefundAmount())
                .refundReason(paymentRefund.getRefundReason())
                .refundStatus(paymentRefund.getRefundStatus())
                .auditor(paymentRefund.getAuditor())
                .auditTime(paymentRefund.getAuditTime())
                .auditOpinion(paymentRefund.getAuditOpinion())
                .thirdRefundNo(paymentRefund.getThirdRefundNo())
                .refundTime(paymentRefund.getRefundTime())
                .refundChannel(paymentRefund.getRefundChannel())
                .remark(paymentRefund.getRemark())
                .createTime(paymentRefund.getCreateTime())
                .createBy(paymentRefund.getCreateBy())
                .build();
    }
}